import { takeEvery, put } from 'redux-saga/effects';
import { GET_INIT_LIST } from './actionTypes';
import { initTodoList } from './actionCreators';
import axios from 'axios';

function* getInitList() {
	try {
		const res = yield axios.get('/mocker/test.json');
		const action = initTodoList(res.data.list);
		yield put(action);
	} catch(e) {
		console.log('请求异常');
	}
}

// generator
function* mySagas(){
	yield takeEvery(GET_INIT_LIST, getInitList);
}

export default mySagas;